<?php

//
// Process method calls to the SessionManager object.
//
class vi_SessionManager extends vi_Service
{
    //
    // Login to the server. Throws an exception if the login failed.
    //
    public function Login($username, $password)
    {
        //
        // Initialize the message and the parameters.
        //
        $parms = array('userName' => $username,
                       'password' => $password);
        $msg = new vi_Message('Login', $parms);

        //
        // Perform the method call and parse the results.
        //
        $result = $this->svc->call($msg, $this->ServiceReference());
        if ($result === false)
            throw new Exception($this->svc->errorMessage);
    }


    //
    // Logout from the server and terminate the current session.
    // A call to Login will have to be made again before other
    // commands can be called.
    //
    public function Logout()
    {
        //
        // Initialize the message and the parameters.
        //
        $msg = new vi_Message('Logout');

        //
        // Perform the method call and parse the results.
        //
        $result = $this->svc->call($msg, $this->ServiceReference());
        if ($result === false)
            throw new Exception($this->svc->errorMessage);
    }
}


?>
